import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hippo_app/utils/common_util.dart';
import 'package:hippo_app/values/size_value.dart';
import 'package:hippo_app/values/style_value.dart';
import 'package:hippo_app/widgets/ripple_container/ripple_container.dart';

class AppTransparentHeader extends StatelessWidget {
  final Widget? child;
  final double? marginLeft;
  final double? marginRight;
  final Widget? appBar;

  final Widget? appBarRight;
  final Widget? appBarLeft;
  final Widget? appBarCenter;

  final bool backVisible;
  final Color? backColor;

  const AppTransparentHeader({
    super.key,
    this.child,
    this.marginRight,
    this.marginLeft,
    this.appBar,
    this.appBarRight,
    this.appBarLeft,
    this.appBarCenter,
    this.backVisible = false,
    this.backColor = Colors.white,
  });

  toPage(BuildContext context) {
    Navigator.pop(context);
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        child ?? Container(),
        Positioned(
          top: CommonUtil.getAppHeaderTop(context),
          left: marginLeft ?? SizeValue.appContentPadding,
          right: marginRight ?? SizeValue.appContentPadding,
          child:
              appBar ??
              Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  if (backVisible)
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        RippleContainer(
                          borderRadius: BorderRadius.circular(100),
                          onTap: () {
                            toPage(context);
                          },
                          child: Container(
                            padding: EdgeInsets.all(4),
                            decoration: BoxDecoration(
                              boxShadow: [StyleValue.defaultCardBoxShadow],
                              color: Colors.black26,
                              borderRadius: BorderRadius.all(
                                Radius.circular(100),
                              ),
                            ),
                            child: Icon(
                              CupertinoIcons.left_chevron,
                              size: 20,
                              color: backColor,
                            ),
                          ),
                        ),
                        Container(
                          margin: EdgeInsets.only(left: 5),
                          child: appBarLeft ?? Container(),
                        ),
                      ],
                    ),
                  appBarCenter ?? Container(),
                  appBarRight ?? Container(),
                ],
              ),
        ),
      ],
    );
  }
}
